<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>TEST1</h2>
<hr>
<h1>Demo1</h1>
<hr>
<h2>项目路径：${ctxPath}</h2>
<hr>
<h2>后台模板数据：${username}</h2>
<hr>

<%
var a = 21;
var b = 31;
var res = a + b;
%>
hello 2 + 3 = ${res}
<h1>${res}</h1>
<hr>
<%
    for(user in session.userList) {
        print(userLP.index);
        print(user.username);
        print(user.age);
    }
    print("                    ");
    print(username);
%>
<hr>
<ul>
    <%
    for (user in users) { %>
        <li>${userLP.index} == ${user.username} == ${user.age}</li>
    <% } %>
</ul>

<%
    var userList2 = users;
%>

<hr>
<%
    var acd = 1;
%>
<h1>${acd == 1 ? '呵呵呵' : '哈哈哈'}</h1>
<hr>
<p>map</p>
<%
    for (m in map) {
        %>
    <p>${m.key} --- ${m.value}</p>
<%
    }
%>
<hr>
<%
    var test1 = [1,2,3,4,5,6];
    for (var i = 0; i < test1.~size; i++) {
        print(test1[i] + " -- ");
    }
%>
<hr>
<%
    var list = [];
    for (item in list) {
        print(item);
    } elsefor {
        print("没有任何记录！");
    }
%>
<hr>
<%
    var userSize = userList.~size;
    print(userSize);
%>
<h1>长度为：${userSize}</h1>

<script>
    //获取项目路径
    const path = "${ctxPath}";
    console.log(path)

    // console.log(userList2);

    // for(user in session["userList"]) {
    //     console.log(user);
    // }
    var userList = "${session.userList}";
    console.log(userList);
    var jsonUserLIst = JSON.stringify(userList);
    console.log(jsonUserLIst);
    // for (var user in jsonUserLIst) {
    //     console.log(user);
    // }

    var users = "${users}";
    for (var user in JSON.stringify(users)) {
        console.log(user);
    }


    // function f() {
    //     for (let i = 0; i < users.length; i++) {
    //         console.log(users[i]);
    //     }
    // }
    // f();


    // const userList = "${session.userList}";
    // console.log("aaaaaaa");
    // console.log(JSON.stringify(userList))
    // for (let user in userList) {
    //     console.log(user.username + ' -- ' + user.age)
    // }
    //
    // const users = "${users}"
    // console.log(users)
    // console.log(users.length)
    //
    //
    //
    // console.log(userListby)
    //
    // const userListby = ${users}
    // var users=${users}
</script>
</body>
</html>